home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-16 | 8.2 KB | 249 lines | [TEXT/MMCC] |
-
- /* mmMD_My_Modeless Handle this dialog */
- /* Copyright © 1994 George R. Cossey */
-
- /* File name: mmMD_My_Modeless.c
- Function: Handle this modeless dialog.
-
- This dialog is called when:
-
- History: 1/16/94 Original by George Cossey
-
- */
-
- #include "mmCommonMM_Demo.h" /* Common */
- #include "CommonMM_Demo.h" /* Common */
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* Routine: Init */
- /* Purpose: This procedures purpose is to set the window pointer to nil, */
- /* this is used to tell the other routines */
-
- void CmmMDMy_Modeless::Init()
- {
-
-
- inherited::Init();
-
- this->Enable_OK5 = true; /* Button */
- this->Enable_Cancel4 = true; /* Button */
- this->Enable_My_Scroll_bar = true; /* ScrollBar */
- this->Value_My_Scroll_bar = 1;
- this->Enable_The_Icon = true; /* Icon button */
- this->Enable_The_Sicn = true; /* Sicn button */
- this->Enable_Tool_palette = true; /* Palette */
- this->Value_Tool_palette = 0;
- }
-
- /* ======================================================= */
-
- /* Routine: Update */
- /* Purpose: This procedures purpose is to refresh this window, update it, */
- /* when we are uncovered by another window. */
-
- void CmmMDMy_Modeless::Update(WindowPtr theWindow)
- {
- GrafPtr SavedPort; /* Save the current port so we can restore to it */
- Rect tempRect; /* Temporary rectangle variable */
- Rect rTempRect; /* Temporary rectangle variable */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- RGBColor Saved_ForeColor; /* Place to save colors */
- RGBColor Saved_BackColor; /* Place to save colors */
- RGBColor DrawingColor; /* Place to make colors */
-
-
- if ((this->theWindow != nil) && (theWindow == this->theWindow))/* Only do if we are the window to update */
- {
- GetPort(&SavedPort); /* Get the current port */
- SetPort(theWindow); /* Point to our port for drawing in our window */
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- GetForeColor(&Saved_ForeColor); /* Save the fore color */
- GetBackColor(&Saved_BackColor); /* Save the back color */
-
- RGBForeColor(&Black_ForeColor); /* Set the fore color to Black */
- RGBBackColor(&White_BackColor); /* Set the back color to White */
- } /* End of IF */
-
- /* This is the default selection, when RETURN is pressed. */
- HiliteDefaultButton(theWindow,ResD_OK5);
-
- /* Draw a line, Drawn line */
- PenSize(1,1);
- MoveTo(110,110); /* Horz,vert, Move to starting position */
- LineTo(284,110); /* Horz,vert, Draw to the ending position */
- PenSize(1,1);
-
- TextSize(12);
- TextFont(systemFont); /* Select the Font that we want */
- TextFace(0); /* Select the style that we want */
-
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- RGBForeColor(&Saved_ForeColor); /* Restore the fore color */
- RGBBackColor(&Saved_BackColor); /* Restore the back color */
- }
-
-
- this->UpdateExtras(); /* HOOK, allow user update code */
-
- DrawDialog(theWindow); /* Draw the rest of the controls */
- SetPort(SavedPort); /* Restore the port that we saved at the start */
- }
- }
-
- /* ======================================================= */
-
- /* Routine: Open */
- /* Purpose: This procedures purpose is to open this window and set all */
- /* of the initial conditions, such as default edit text. */
-
- void CmmMDMy_Modeless::Open()
- {
- Rect tempRect; /* Temporary rectangle variable */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- long LTemp,LTemp2,theLong; /* Get selection, temp holding */
- DialogPtr theDialog;
-
-
- if (this->theWindow == NIL)
- {
- this->theWindow = GetNewDialog(ResD_My_Modeless,NIL,(WindowPtr)-1 );/* Bring in the dialog resource */
- theDialog = this->theWindow;
- SetPort(theDialog); /* Prepare to add conditional text */
-
- /* Button */
- SetupNormalControl(theDialog,ResD_OK5,this->Enable_OK5,0);
-
- /* Button */
- SetupNormalControl(theDialog,ResD_Cancel4,this->Enable_Cancel4,0);
-
- /* Draw a Hotspot or Rectangle */
- SetupHotSpot(theDialog,ResD_Message_on_rect,false,1,
- 1,sResD_Message_on_rect,this->Enable_Message_on_rect);
-
- /* Draw a Palette */
- SetupPalette(theDialog,ResD_Tool_palette,this->Enable_Tool_palette,
- 3,3,ResD_N_Tool_palette,6);
-
- /* Draw an Icon button */
- SetupIconSicn(theDialog,ResD_The_Icon,this->Enable_The_Icon,
- ResD_N_The_Icon,ResD_H_The_Icon);
-
- /* Draw a Sicn */
- SetupIconSicn(theDialog,ResD_The_Sicn,this->Enable_The_Sicn,
- ResD_N_The_Sicn,ResD_H_The_Sicn);
-
- SetupTheItem(theDialog,ResD_My_Scroll_bar,true,true,this->Enable_My_Scroll_bar,true,&tempRect,0,0);
- SetupMinMaxValue(theDialog,ResD_My_Scroll_bar,1,100,this->Value_My_Scroll_bar);
-
-
-
- this->OpenExtras(); /* Call the user Open procedure */
-
- ShowWindow(theDialog); /* Open a dialog box */
- SelectWindow(theDialog); /* Lets see it */
- }
- else
- SelectWindow(this->theWindow); /* Lets see it */
- }
-
- /* ======================================================= */
-
- /* Routine: Close_My_Modeless */
- /* Purpose: This procedures purpose is to close this window and clear */
- /* the window pointer variable */
-
- void CmmMDMy_Modeless::Close(WindowPtr theWindow)
- {
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
-
-
- if ((this->theWindow != NIL) && (theWindow == this->theWindow))/* Only close if it is us and we were open */
- {
-
- DisposDialog(theWindow); /* Close on the screen and Flush the dialog out of memory */
- this->theWindow = nil; /* Make sure our other routines know that we are closed */
- }
- }
-
- /* ======================================================= */
-
- /* Routine: HandleEvent */
- /* Purpose: This procedures purpose is to handle all actions, such as buttons being pressed. */
- /* This is the real meat of this unit and is where the code is for acting upon the users actions. */
-
- void CmmMDMy_Modeless::HandleEvent(EventRecord *theEvent,WindowPtr theWindow,short itemHit)
- {
- short Index; /* For looping */
- Point myPt; /* For the local mouse position */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- Rect tempRect; /* Temporary rectangle */
- ControlHandle CItem; /* Control handle */
- short temp; /* temp integer */
- short code; /* temp integer */
- short theSelection; /* For Palettes */
- Boolean DoubleClick; /* For sensing double clicks in a list */
- DialogPtr theDialog;
-
-
- this->ExitDialog = false; /* Do not close the dialog yet */
- if ((theEvent->what == mouseDown) && (this->theWindow != nil))
- {
- SetPort(this->theWindow); /* Set the port to our dialog */
- myPt = theEvent->where; /* Get the position where the mouse was pressed */
- GlobalToLocal(&myPt); /* Change from global to local location */
-
- }
-
- if ((this->theWindow != nil) && (this->theWindow == theWindow))
- {
- theDialog = this->theWindow;
-
- CheckKeysInDialog(theDialog,&DoubleClick,theEvent,&itemHit);
-
- myPt = theEvent->where; /* Get the position where the mouse was pressed */
- GlobalToLocal(&myPt); /* Change from global to local location */
-
- this->FilterTheHit(&itemHit,theEvent); /* Give the user the itemhit */
-
- if (itemHit > 0) /* Skip if user set to zero */
- {
- GetDItem(theDialog,itemHit,&DType,&DItem,&tempRect);/* Get which item was pressed */
- CItem = (ControlHandle)DItem; /* Change the pointer for getting to the control */
- }
-
- /* Handle it real time */
- if (itemHit == ResD_OK5) /* Handle the Button being pressed */
- {
- Add_UserEvent(UserEvent_Close_Window,ResD_My_Modeless,0,0,nil); /* Close this modeless dialog */
- this->ExitDialog = true; /* Close this dialog, exit */
- }
-
- if (itemHit == ResD_Cancel4) /* Handle the Button being pressed */
- {
- Add_UserEvent(UserEvent_Close_Window,ResD_My_Modeless,0,0,nil); /* Close this modeless dialog */
- this->ExitDialog = true; /* Close this dialog, exit */
- }
-
- /* Palette */
-
-
- }
-
- if (this->ExitDialog) /* Do the close of the dialog */
- this->Close(this->theWindow);
- }
-
- /* ======================================================= */
- /* ======================================================= */
-